﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace Knife.Core.Util
{
    public class CommonUtil
    {
        public static string GetRootPath()
        {
            //协议
            string Scheme = HttpContext.Current.Request.Url.Scheme;
            //域名
            string Host = HttpContext.Current.Request.Url.Host;
            //端口
            int Port = HttpContext.Current.Request.Url.Port;
            //工程名
            string ApplicationPath = HttpContext.Current.Request.ApplicationPath;
            string RootPath = string.Empty;
            if (Port == 80)
            {
                RootPath = Scheme + "://" + Host + ApplicationPath + "/";
            }
            else
            {
                RootPath = Scheme + "://" + Host + ":" + Port + ApplicationPath + "/";
            }
            return RootPath;
        }
        public static string GetNewGuid()
        {
            return DateTime.Now.ToString("yyyyMMddHHmmss") + Guid.NewGuid().ToString().Substring(0, 36);
        }

    }
}
